package com.starview.star.operators.ast.runtime;

import com.starview.platform.data.EvaluationException;
import com.starview.platform.data.IFunction;
import com.starview.platform.data.IValue;
import com.starview.platform.data.type.IType;
import com.starview.platform.data.type.StandardTypes;
import com.starview.platform.data.type.TypeUtils;
import com.starview.platform.data.value.Factory;
import com.starview.platform.data.value.StringWrap;
import com.starview.star.compiler.ast.ASyntax;
import com.starview.star.operators.CafeEnter;

public class AstCategory implements IFunction
{
  public static final String name = "astCategory";

  @CafeEnter
  public static IValue enter(ASyntax term,StringWrap category) throws EvaluationException
  {
    return Factory.newBool(term.isCategory(Factory.stringValue(category)));
  }

  @Override
  public IValue enter(IValue... args) throws EvaluationException
  {
    return enter((ASyntax) args[0],(StringWrap)args[1]);
  }

  @Override
  public IType getType()
  {
    return type();
  }

  public static IType type()
  {
    return TypeUtils.functionType(ASyntax.type, StandardTypes.stringType,StandardTypes.booleanType);
  }
}
